﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
///ReplyDao 的摘要说明
/// </summary>
public class ReplyDao
{
    DBMM dbm = new DBMM();
    DataTable dt = null;
    string sql = null;
    ReplyVo rv = new ReplyVo();

    //添加留言回复
    public Exception addReply(ReplyVo rv)
    {
        sql = "insert into Reply values(@Rcontent,@Oid,@Rtime,@Uid,@Rauthor)";
        SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@Rcontent", rv.Rcontent), 
                                                 new SqlParameter("@Oid", rv.Oid), 
                                                 new SqlParameter("@Rtime",DateTime.Now.ToString()), 
                                                 new SqlParameter("@Uid", rv.Uid), 
                                                 new SqlParameter("@Rauthor", rv.Rauthor)};
        Exception ex = null;
        ex = dbm.Execute(sql, sp);
        return ex;
    }

    //删除留言回复
    public Exception delReply(string id)
    {
        sql = "delete Reply where Rid=@Rid";
        SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@Rid", id) };
        Exception ex = null;
        ex = dbm.Execute(sql, sp);
        return ex;
    }

    //查找相关留言回复
    public DataTable getReply(string id)
    {
        sql = "select * from Reply where Oid=@Oid";
        SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@Oid", id)};
        dt = new DataTable();
        dt = dbm.GetTable(sql, sp);
        return dt;
    }
}
